package com.huike.business.service.impl;


import com.huike.business.domain.TbBusinessTrackRecord;
import com.huike.business.mapper.TbBusinessTrackRecordMapper;
import com.huike.business.service.ITbBusinessTrackRecordService;
import com.huike.clues.mapper.SysDictTypeMapper;
import org.checkerframework.checker.units.qual.A;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

/**
 * 商机跟进记录Service业务层处理
 *
 * @author wgl
 * @date 2021-04-28
 */
@Service
public class TbBusinessTrackRecordServiceImpl implements ITbBusinessTrackRecordService {
    @Autowired
    private TbBusinessTrackRecordMapper tbBusinessTrackRecordMapper;
    @Autowired
    private SysDictTypeMapper sysDictTypeMapper;


    @Override
    public List<TbBusinessTrackRecord> leadFollowUp(Long id) {
        List<TbBusinessTrackRecord> trackRecords = tbBusinessTrackRecordMapper.trackRecords(id);
        for (TbBusinessTrackRecord trackRecord : trackRecords) {
            String keyItems = trackRecord.getKeyItems();
            String[] split = keyItems.split(",");
            ArrayList<String> list = new ArrayList<>();
            for (String s : split) {
                String key = sysDictTypeMapper.find(s);
                list.add(key);
            }
            trackRecord.setKeys(list);
        }
        return trackRecords;
    }
}
